c# get the last item in a list

89

c# get last item in list -

using System.Linq; // make sure to use System.Linq

List<string> list = new List<string>
{
	"one",
	"two",
	"three",
};
var lastItem = list.LastOrDefault();
//Or
var lastItem = list.Last();

c# get the last item in a list -

var lastItem = integerList.Last();

get last element in a list vb.net -

if(integerList.Count>0)
{
   var item = integerList[integerList.Count - 1];
}

Comments

Submit
0 Comments